#0. Prepare execution CC "Application" GET_PATH append-delimiter SET sADOxxPath:(path) CC "AdoScript" FILE_EXISTS file:(sADOxxPath + "curl.exe") IF (exists = 0) { CC "AdoScript" FILE_COPY from:"db:\\curl.exe" to:(sADOxxPath + "curl.exe") } CC "AdoScript" FILE_EXISTS file:(sADOxxPath + "wget.exe") IF (exists = 0) { CC "AdoScript" FILE_COPY from:"db:\\wget.exe" to:(sADOxxPath + "wget.exe") } SETG sLocation:(sADOxxPath) # Update mechanism for model/instance information into a collaborative environment, such as wiki # Preset: nProcessedModel # 1. Parse model information # Get information on the model, to construct a unique name for the wiki page: # ModelName + ModelVersion + Modeltype # location of the AdoScript and curl/wget extensions - needs to be a file location and not db:\\ CC "Modeling" GET_ACT_MODEL SET nProcessedModel:(modelid) CC "Core" GET_MODEL_INFO modelid:(nProcessedModel) # RESULT: modelname:strValue ver:strValue version:strValue threadid:id modeltype:strValue libid:id libtype:LibType libname:strValue access:Access ecode:intValue SETL sUniqueWikiPageName: (modelname + " " + version + " (" + modeltype + ")") CC "AdoScript" MSGWIN ("Wiki view is generated for Model \"" + sUniqueWikiPageName + "\"") # get a temp file handler to store result CC "AdoScript" GET_TEMP_FILENAME # RESULT filename:strValue # API calls are encoded in base64 to ensure special characters are treated correctly SYSTEM (sLocation + "wget.exe -O "+filename+" http://moodle.boc-group.eu/mediawiki_adoxx/createpage.php?pagename=" + base64encode (sUniqueWikiPageName)) #with-console-window #CC "AdoScript" EDITBOX text:(sLocation + "wget.exe -O "+filename+" http://moodle.boc-group.eu/mediawiki_adoxx/createpage.php?pagename=" + base64encode (sUniqueWikiPageName)) CC "AdoScript" FREAD file:(filename) SETL sSuccess:(text) IF (sSuccess = "Success") { # 2. export/transform model image #CC "AdoScript" INFOBOX "Warning!" CC "Drawing" GEN_GFX_STR modelid:(nProcessedModel) gfx-format:"png" scale:1.0 CC "AdoScript" FWRITE file:(sLocation + ""+STR nProcessedModel+".png") text:(gfx) base64 SYSTEM (sLocation + "curl.exe -F \"file=@" + sLocation +STR nProcessedModel+".png;filename="+STR nProcessedModel+".png\" http://moodle.boc-group.eu/mediawiki_adoxx/upload.php") #with-console-window SYSTEM (sLocation + "wget.exe -O "+filename+" http://moodle.boc-group.eu/mediawiki_adoxx/createsection.php?pagename=" + base64encode (sUniqueWikiPageName) + "§ionname=" + base64encode ("Model representation") + "§iontext=" +base64encode ("http://moodle.boc-group.eu/mediawiki_adoxx/"+STR nProcessedModel+".png")) #with-console-window CC "AdoScript" QUERYBOX "Export instances?" yes-no def-no IF (endbutton ="yes") { # write all modelattributes to wiki WRITE_ATTRIBUTES_TO_WIKI id:(nProcessedModel) isModel:1 CC "Core" GET_ALL_OBJS modelid:(nProcessedModel) # RESULT ecode:intValue objids:strValue SETL lProcessedObjIDs:(objids) # add information on number of objects in model SYSTEM (sLocation + "wget.exe -O "+filename+" http://moodle.boc-group.eu/mediawiki_adoxx/appendtext.php?pagename=" + base64encode (sUniqueWikiPageName) + "&pagetext=" + base64encode ("Number of instances in model: " + STR tokcnt(lProcessedObjIDs))) #with-console-window SYSTEM (sLocation + "wget.exe -O "+filename+" http://moodle.boc-group.eu/mediawiki_adoxx/createsection.php?pagename=" + base64encode (sUniqueWikiPageName) + "§ionname=" + base64encode ("Instance overview") + "§iontext=" +base64encode ("''Hyperlinked summary''")) #with-console-window # 3. Parse instance information FOR sProcessedObjID in:(lProcessedObjIDs) { # Type conversion from STRING TO VAL SETL nProcessedObjID:(VAL sProcessedObjID) # Get all objectinformation to construct a unique Wiki page name # ObjectName + ObjectClass + ModelName + ModelVersion + Modeltype CC "Core" GET_OBJ_NAME objid:(nProcessedObjID) # RESULT ecode:intValue objname:strValue SETL sProcessedObjectName:(objname) # Get the classid of the objects CC "Core" GET_CLASS_ID objid:(nProcessedObjID) # RESULT ecode:intValue classid:intValue CC "Core" GET_CLASS_NAME classid:(classid) # RESULT ecode:intValue classname:strValue isrel:intValue SETL sProcessedClassName:(classname) SETL sUniqueObjectWikiPageName:(sProcessedObjectName + " (" +sProcessedClassName + ") ") CC "AdoScript" MSGWIN ("Wiki view is generated for Instance \"" + sUniqueObjectWikiPageName + "\"") SYSTEM (sLocation + "wget.exe -O "+filename+" http://moodle.boc-group.eu/mediawiki_adoxx/createpage.php?pagename=" + base64encode (sUniqueObjectWikiPageName)) #with-console-window SYSTEM (sLocation + "wget.exe -O "+filename+" http://moodle.boc-group.eu/mediawiki_adoxx/appendtext.php?pagename=" + base64encode (sUniqueWikiPageName) + "&pagetext=" + base64encode ("[[" + sUniqueObjectWikiPageName + "|"+sProcessedObjectName+" (" +sProcessedClassName+ ")]]")) #with-console-window # add notebook information WRITE_ATTRIBUTES_TO_WIKI id:(nProcessedObjID) isModel:0 # 4. Store target pointer in instance CC "Core" SET_ATTR_VAL objid:(nProcessedObjID) attrname:("Wiki view") val:("ITEM \"\" param:\"http://moodle.boc-group.eu/mediawiki/index.php/" + sUniqueObjectWikiPageName+"\"") } # 5. Store target pointer for Wiki Class CC "Core" GET_CLASS_ID classname:"Wiki" SETL sWikiID:(classname) #IF (sWikiID != 0) #{ #CC "AdoScript" ERRORBOX "Your library does not contain a class called Wiki!\n" #EXIT #} CC "Core" SET_ATTR_VAL classid:(sWikiID) attrname:("Wiki view") val:("ITEM \"\" param:\"http://moodle.boc-group.eu/mediawiki/index.php/" + sUniqueWikiPageName+"\"") CC "AdoScript" MSGWIN hide } SET sUniqueWikiPageName:(replall(sUniqueWikiPageName, " ", "_")) SYSTEM START ("http://moodle.boc-group.eu/mediawiki/index.php/" + sUniqueWikiPageName) } PROCEDURE WRITE_ATTRIBUTES_TO_WIKI id:integer isModel:integer { IF (isModel) { CC "Core" GET_ALL_ATTRS modeltype:(modeltype) # RESULT ecode:intValue attrids:strValue SETL lNotebookAttrIDs:(attrids) SETL sWikiPage:(sUniqueWikiPageName) } ELSE { CC "Core" GET_CLASS_ID objid:(id) CC "Core" GET_ALL_ATTRS classid:(classid) # RESULT ecode:intValue attrids:strValue SETL lNotebookAttrIDs:(attrids) SETL sWikiPage:(sUniqueObjectWikiPageName) } # create a section and append SYSTEM (sLocation + "wget.exe -O "+filename+" http://moodle.boc-group.eu/mediawiki_adoxx/createsection.php?pagename=" + base64encode (sWikiPage) + "§ionname=" + base64encode ("Notebook information") + "§iontext=" +base64encode ("''The following information is available in the notebook.''")) #with-console-window # iterate through all attributes and create respective wiki entries FOR sNotebookAttrID in:(lNotebookAttrIDs) { SETL nNotebookAttrID:(VAL sNotebookAttrID) CC "Core" GET_ATTR_TYPE attrid:(nNotebookAttrID) # RESULT ecode:intValue attrtype:strValue IF (attrtype = "STRING" OR attrtype = "LONGSTRING") { CC "Core" GET_ATTR_NAME attrid:(nNotebookAttrID) # RESULT ecode:intValue attrname:strValue CC "Core" GET_ATTR_VAL objid:(id) attrid:(nNotebookAttrID) as-string # RESULT ecode:intValue val:anyValue SYSTEM (sLocation + "wget.exe -O "+filename+" http://moodle.boc-group.eu/mediawiki_adoxx/appendtext.php?pagename=" + base64encode (sWikiPage) + "&pagetext=" + base64encode ("''"+attrname+":'' " + val)) #with-console-window } } }